cmake_minimum_required(VERSION 3.24)
project(00_hello_triangle)

set(CMAKE_CXX_STANDARD 17)

# 定义平台为Windows
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)

# Vulkan
find_package(Vulkan REQUIRED)
if(Vulkan_FOUND)
    message("Find vulkan success!")
    include_directories(${Vulkan_INCLUDE_DIRS})
endif()

set(glfw3_DIR "C:/Program Files (x86)/GLFW/lib/cmake/glfw3")
set(glfw3_INCLUDE_DIRS "C:/Program Files (x86)/GLFW/include")
set(glfw3_LIBRARY "C:/Program Files (x86)/GLFW/lib/libglfw3.a")

# GLFW3
find_package(glfw3 REQUIRED)
if(glfw3_FOUND)
    message("Find glfw3 success!")
    include_directories(${glfw3_INCLUDE_DIRS})
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

file(COPY shaders DESTINATION .)
include(SPIR-V)

# 使用SHADERS暂存shader文件列表
set(SHADERS
        shaders/demo001.frag
        shaders/demo001.vert
        # shaders/demo002.frag
        # shaders/demo002.vert
        # ...
        # ...
        )
# 编译为中间文件
spirv_shaders(
        SHADER_HEADERS
        SPIRV_VERSION
        1.0 # Currently targeting Vulkan 1.0
        SOURCES
        ${SHADERS}
)

add_executable(
        ${PROJECT_NAME}
        ${SHADER_HEADERS}
        src/VulkanCommon.h
        src/Main.cpp
        src/VkBundle.h
        src/VkHelper.cpp
        src/VkHelper.h
)

target_link_libraries(${PROJECT_NAME} PUBLIC ${Vulkan_LIBRARY} ${glfw3_LIBRARY})
